<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>俱乐部信息</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/static/admin/style.css}" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form layui-form-pane" action="">
                <input name="id" th:value="${obj?.id}" class="layui-input layui-hide"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">俱乐部名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="clubName" th:value="${obj?.clubName}"
                               lay-verify="required|username"
                               placeholder="请输入俱乐部名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">俱乐部负责人</label>
                    <div class="layui-input-block">
                        <input type="text" name="clubLeader" th:value="${obj?.clubLeader}"
                               lay-verify="required|username"
                               placeholder="请输入俱乐部负责人" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">创建时间</label>
                    <div class="layui-input-block">
                        <input type="text" readonly disabled name="createTime" id="createTime"
                               th:value="${obj?.strCreationTime}" lay-verify="required|datetime"
                               placeholder="请输入创建时间"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">俱乐部类型</label>
                    <div class="layui-input-block">
                        <select name="typeId" disabled id="typeId"></select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">活动次数</label>
                    <div class="layui-input-block">
                        <input type="text" name="numberOfActivities" th:value="${obj?.numberOfActivities}"
                               lay-verify="required|positiveInteger"
                               placeholder="请输入活动次数" readonly autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">会员数量</label>
                    <div class="layui-input-block">
                        <input type="text" name="numberOfMembers" th:value="${obj?.numberOfMembers}"
                               lay-verify="required|positiveInteger"
                               placeholder="请输入会员数量" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="remark" readonly th:text="${obj?.remark}" placeholder="请输入备注"
                                  autocomplete="off" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <input type="button" lay-submit lay-filter="LAY-front-submit" id="LAY-front-submit" value="确认">
                </div>
            </form>
        </div>
    </div>
</div>
<script th:src="@{/static/layui/layui.js}"></script>
<script>
    layui.use(['form', 'laydate'], function () {
        var $ = layui.$;
        var laydate = layui.laydate;
        var form = layui.form;

        //支持日期控件
        laydate.render({
            elem: '#createTime',
            type: 'datetime',
            // value: new Date(),
            max: new Date().toLocaleString(),
            // trigger: 'click'
        });

        form.verify({
            username: function (value, item) { //value：表单的值、item：表单的DOM对象
                if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
                    return '名称不能有特殊字符';
                }
                if (/(^\_)|(\__)|(\_+$)/.test(value)) {
                    return '名称首尾不能出现下划线\'_\'';
                }
                if (/^[0-9]\d*$/.test(value)) {
                    return '名称不能全为数字';
                }
            }
            , positiveInteger: [
                /^[+]{0,1}(\d+)$/,
                '活动次数和会员数量必须为正整数！'
            ]
        });

        //当前俱乐部类型的值
        var currentClubTypeId = '[[${obj?.typeId}]]';
        //获取俱乐部类型列表
        $.ajax({
            url: '/clubType/clubTypeList',
            dataType: 'json',
            type: 'post',
            cache: false,
            success: function (data) {
                $('#typeId').prepend("<option value=''>请选择</option>");
                for (var i = 0; i < data.data.length; i++) {
                    if (data.data[i].id == currentClubTypeId) {
                        $('#typeId').append("<option selected value='" + data.data[i].id + "'>" + data.data[i].typeName + "</option>");
                    } else {
                        $('#typeId').append("<option value='" + data.data[i].id + "'>" + data.data[i].typeName + "</option>");
                    }
                }
                form.render();          //下拉列表渲染，把内容加载进去
            }
        });
    });
</script>
</body>
</html>
















